package com.kisszpy.system.dao;

import java.util.LinkedHashMap;
import java.util.List;

import com.kisszpy.core.dao.HibernateGenericDao;
import com.kisszpy.core.utils.PageModel;
import com.kisszpy.system.entity.SysUser;
import com.sun.org.apache.bcel.internal.classfile.PMGClass;

public class SysUserDao extends HibernateGenericDao<SysUser>{
	/***
	 * 用户登录
	 * @param entity
	 * @return
	 */
	public SysUser login(SysUser entity){
		String hql = "from SysUser o where o.username = ? and o.password = ? and o.status = 0";
		List<SysUser> list = this.executeQueryByHQL(hql, new Object[]{entity.getUsername(),entity.getPassword()});
		if(!list.isEmpty()){
			if(list.get(0)!=null){
				return list.get(0);
			}
		}
		return null;
	}
	public PageModel<SysUser> getAll(int pageNow,int pageSize){
		LinkedHashMap<String, String> orderBy = new LinkedHashMap<String, String>();
		orderBy.put("id", "desc");
		return this.getAllEntity(SysUser.class, pageNow, pageSize, "o.status=?",new Object[]{0},orderBy);
	}
}
